package com.yl.web.controller.api;

import com.yl.common.annotation.Anonymous;
import com.yl.common.core.domain.AjaxResult;
import com.yl.domain.TopicDO;
import com.yl.service.TopicService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 无领导小组讨论 职业管理
 * @author : y
 * @date :  2024/6/26 9:50
 **/
@RequestMapping("/topic")
@RestController
@Anonymous
public class TopicController {
    private static final Logger log = LoggerFactory.getLogger(TopicController.class);

    @Resource
    TopicService topicService;


    @RequestMapping("/saveTopic")
    @ResponseBody
    public AjaxResult saveTopic(@RequestBody TopicDO topicDO) {
        log.info("创建/修改话题=======入参={}", topicDO);
        return topicService.saveTopic(topicDO);
    }


    @RequestMapping("/getTopicPage")
    @ResponseBody
    public AjaxResult getTopicPage(@RequestBody TopicDO topicDO) {
        log.info("查看话题列表=======入参={}", topicDO);
        return topicService.listTopic(topicDO);
    }

    @RequestMapping("/deleteTopicPage")
    @ResponseBody
    public AjaxResult deleteTopicPage(@RequestBody TopicDO topicDO) {
        log.info("删除话题=======入参={}", topicDO);
        return topicService.deleteTopic(topicDO);
    }


    @RequestMapping("/getTopicById")
    @ResponseBody
    public AjaxResult getTopicById(@RequestBody TopicDO topicDO) {
        log.info("查看话题详情=======入参={}", topicDO);
        if (topicDO.getId() == null) {
            return AjaxResult.error("参数为空");
        }
        return topicService.getTopicById(topicDO.getId());
    }

}
